<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>闭包html</title>

</head>

<body>
    <div id="container">
        <button id="btn">点击</button>
    </div>
    <script type="text/javascript">
        var btn = document.getElementById('btn')
        //   btn.onclick=function(){
        //        console.log('老子点击了')
        //   }
        for (let i = 0; i < 10; i++) {
            (function (index) {
                console.log('index', index)
            })(i)
        }
    </script>
</body>

</html>